package top.kaoshanji.s1ch09a;

import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;

/**
 * 代码清单-s1ch09a-187页a：使用@RequestScope注解定义bean的作用域是请求作用域
 * @author kaoshanji
 * ^_^
 * create time 2025/4/30 15:40
 */
@Component
@RequestScope
public class LoginProcessor {

    private String username;
    private String password;

    // 创建此对象，然后通过set方法为属性赋值，才能调用此方法
    public boolean login() {
        boolean result = false;
        String userName = this.username;
        String passWord = this.password;

        if ("me123".equals(userName) && "ps456".equals(passWord)) {
            result = true;
        }

        return result;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
